package cn.tedu.controller;


import cn.tedu.pojo.UserInfo;
import cn.tedu.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class UserInfoController {


    @Autowired
    private UserInfoService userInfoService;


    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String Userlogin(String username,String password){
        UserInfo userInfo = new UserInfo(username, password);
        Integer userlogin = userInfoService.Userlogin(userInfo);
        if (userlogin>0){
            return "product_list";
        }
        return "login";
    }

    @RequestMapping(value = "/zhuce",method = RequestMethod.POST)
    public String zhuce(String username,String password){
        Integer zhuce = userInfoService.zhuce(new UserInfo(username, password));
        if (zhuce>0){
            return "login";
        }
        return "zhuCe";
    }

    @RequestMapping(value = "/gologin",method = RequestMethod.GET)
    public String gologin(){
        return "login";
    }

    @RequestMapping(value = "/goZhuCe",method = RequestMethod.GET)
    public String goZhuCe(){
        return "zhuCe";
    }
}
